@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

:root {
    /* --- 默认暗色主题 (墨色系) --- */
    --primary-bg-dark: #1a1b1e;
    --secondary-bg-dark: #2a2c30;
    --tertiary-bg-dark: #202124;
    --accent-bg-dark: #3a3a3e;
    --primary-text-dark: #e8eaed;
    --secondary-text-dark: #9aa0a6;
    --highlight-text-dark: #8ab4f8;
    --border-color-dark: #3c4043;
    --button-bg-dark: #303134;
    --button-hover-bg-dark: #3c4043;
    --danger-color-dark: #f28b82;
    --danger-hover-bg-dark: #ea6b66;
    --input-bg-dark: #202124;
    --scrollbar-track-dark: rgba(40, 40, 40, 0.5);
    --scrollbar-thumb-dark: rgba(100, 100, 100, 0.6);
    --scrollbar-thumb-hover-dark: rgba(120, 120, 120, 0.8);
    --cpu-color-dark: #8ab4f8;
    --memory-color-dark: #81c995;

    /* --- 亮色主题 --- */
    --primary-bg-light: #f8f9fa;
    --secondary-bg-light: #ffffff;
    --tertiary-bg-light: #f1f3f4;
    --accent-bg-light: #e8eaed;
    --primary-text-light: #202124;
    --secondary-text-light: #5f6368;
    --highlight-text-light: #1a73e8;
    --border-color-light: #dadce0;
    --button-bg-light: #e8eaed;
    --button-hover-bg-light: #dfe1e5;
    --danger-color-light: #d93025;
    --danger-hover-bg-light: #c5221f;
    --input-bg-light: #ffffff;
    --scrollbar-track-light: rgba(200, 200, 200, 0.5);
    --scrollbar-thumb-light: rgba(150, 150, 150, 0.6);
    --scrollbar-thumb-hover-light: rgba(120, 120, 120, 0.8);
    --cpu-color-light: #1a73e8;
    --memory-color-light: #1e8e3e;
}


html[data-theme='dark'] {
    --primary-bg: var(--primary-bg-dark);
    --secondary-bg: var(--secondary-bg-dark);
    --tertiary-bg: var(--tertiary-bg-dark);
    --accent-bg: var(--accent-bg-dark);
    --primary-text: var(--primary-text-dark);
    --secondary-text: var(--secondary-text-dark);
    --highlight-text: var(--highlight-text-dark);
    --border-color: var(--border-color-dark);
    --button-bg: var(--button-bg-dark);
    --button-hover-bg: var(--button-hover-bg-dark);
    --danger-color: var(--danger-color-dark);
    --danger-hover-bg: var(--danger-hover-bg-dark);
    --input-bg: var(--input-bg-dark);
    --scrollbar-track: var(--scrollbar-track-dark);
    --scrollbar-thumb: var(--scrollbar-thumb-dark);
    --scrollbar-thumb-hover: var(--scrollbar-thumb-hover-dark);
    --cpu-color: var(--cpu-color-dark);
    --memory-color: var(--memory-color-dark);
    color-scheme: dark;
}

html[data-theme='light'] {
    --primary-bg: var(--primary-bg-light);
    --secondary-bg: var(--secondary-bg-light);
    --tertiary-bg: var(--tertiary-bg-light);
    --accent-bg: var(--accent-bg-light);
    --primary-text: var(--primary-text-light);
    --secondary-text: var(--secondary-text-light);
    --highlight-text: var(--highlight-text-light);
    --border-color: var(--border-color-light);
    --button-bg: var(--button-bg-light);
    --button-hover-bg: var(--button-hover-bg-light);
    --danger-color: var(--danger-color-light);
    --danger-hover-bg: var(--danger-hover-bg-light);
    --input-bg: var(--input-bg-light);
    --scrollbar-track: var(--scrollbar-track-light);
    --scrollbar-thumb: var(--scrollbar-thumb-light);
    --scrollbar-thumb-hover: var(--scrollbar-thumb-hover-light);
    --cpu-color: var(--cpu-color-light);
    --memory-color: var(--memory-color-light);
    color-scheme: light;
}

body {
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    margin: 0;
    padding-top: 60px;
    background-color: var(--primary-bg);
    color: var(--primary-text);
    font-size: 16px;
    line-height: 1.6;
}

.container {
    display: flex;
    height: calc(100vh - 60px);
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background-color: var(--secondary-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.5em;
    color: var(--primary-text);
    margin: 0 0 15px 0;
    font-weight: 600;
}

#sidebar-search {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--primary-text);
    font-size: 0.9em;
    box-sizing: border-box;
}

#sidebar-search:focus {
    outline: none;
    border-color: var(--highlight-text);
    box-shadow: 0 0 0 2px var(--highlight-text);
}

.sidebar nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
}

.sidebar nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.sidebar nav li a {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--secondary-text);
    padding: 12px 15px;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.95em;
    font-weight: 500;
}

.sidebar nav li a:hover {
    background-color: var(--accent-bg);
    color: var(--primary-text);
}

.sidebar nav li a.active {
    background-color: var(--highlight-text);
    color: white;
    font-weight: 600;
}

.sidebar nav li.nav-category {
    padding: 15px 15px 5px;
    font-size: 0.8em;
    color: var(--secondary-text);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar .material-symbols-outlined {
    font-size: 22px;
}

.content {
    flex-grow: 1;
    padding: 30px 40px;
    box-sizing: border-box;
    overflow-y: auto;
}

.config-section {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.config-section.active-section {
    display: block;
}

.config-section h2 {
    font-size: 2em;
    color: var(--primary-text);
    margin-top: 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    font-weight: 600;
}
 
/* VCP Animation Styles */
.vcp-animation-container {
    position: relative;
    width: 100%;
    height: 250px;
    margin-bottom: 30px;
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
}

#vcp-animation-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.vcp-logo-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    text-align: center;
}

.vcp-logo {
    max-width: 800px;
    max-height: 80%;
    height: auto;
    animation: laser-outline-orbit 4s infinite linear;
}

@keyframes laser-outline-orbit {
    0% {
        filter: drop-shadow(0 -7px 4px var(--highlight-text));
    }
    25% {
        filter: drop-shadow(7px 0 4px var(--highlight-text));
    }
    50% {
        filter: drop-shadow(0 7px 4px var(--highlight-text));
    }
    75% {
        filter: drop-shadow(-7px 0 4px var(--highlight-text));
    }
    100% {
        filter: drop-shadow(0 -7px 4px var(--highlight-text));
    }
}


 /* Dashboard Styles */
 .dashboard-grid {
     display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.status-card {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

html[data-theme='dark'] .status-card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.status-card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1em;
    color: var(--primary-text);
    font-weight: 600;
}

.status-card-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.progress-circle svg {
    transform: rotate(-90deg);
}

.progress-circle .progress-bg {
    fill: none;
    stroke: var(--tertiary-bg);
    stroke-width: 10;
}

.progress-circle .progress-bar {
    fill: none;
    stroke: var(--highlight-text);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 339.292; /* 2 * PI * 54 */
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 0.5s ease-out;
}

.cpu-card .progress-bar { stroke: var(--cpu-color); }
.memory-card .progress-bar { stroke: var(--memory-color); }

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary-text);
}

#cpu-info-text, #mem-info-text {
    font-size: 0.9em;
    color: var(--secondary-text);
    line-height: 1.4;
}

#pm2-process-list, #node-info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.process-item, .node-info-item {
    font-size: 0.9em;
}

.process-item .status {
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.8em;
    font-weight: 600;
    color: white;
}
.process-item .status.online { background-color: #1e8e3e; }
.process-item .status.stopped, .process-item .status.errored { background-color: #d93025; }
.process-item .status.launching { background-color: #f9ab00; }

.node-info-item strong {
    color: var(--primary-text);
}


/* Top Bar */
.top-bar {
    background-color: var(--secondary-bg);
    color: var(--primary-text);
    padding: 0 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-sizing: border-box;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
}
.top-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}
.server-title {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--primary-text);
}
.header-actions {
    display: flex;
    gap: 15px;
}

.restart-button,
.theme-button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: background-color 0.2s ease;
    background-color: var(--button-bg);
    color: var(--primary-text);
}
.restart-button {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}
.restart-button:hover {
    background-color: var(--danger-hover-bg);
    border-color: var(--danger-hover-bg);
}
html[data-theme='light'] .restart-button {
    color: white;
}
.theme-button:hover {
    background-color: var(--button-hover-bg);
}

/* Other sections... */
form { display: flex; flex-direction: column; gap: 22px; }
.form-group { display: flex; flex-direction: column; gap: 10px; padding: 18px; background-color: var(--secondary-bg); border-radius: 8px; border: 1px solid var(--border-color); }
.form-group:focus-within { box-shadow: 0 0 0 2px var(--highlight-text); }
.form-group label { font-weight: 600; font-size: 1em; }
.form-group .description { font-weight: normal; font-size: 0.88em; color: var(--secondary-text); }
.form-group input[type="text"], .form-group input[type="password"], .form-group input[type="number"], .form-group textarea, .form-group select {
    width: 100%; padding: 12px 15px; border: 1px solid var(--border-color); border-radius: 6px;
    background-color: var(--input-bg); color: var(--primary-text); font-size: 0.95em; box-sizing: border-box;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--highlight-text); }
.form-actions { display: flex; gap: 15px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-color); }
button, input[type="submit"] {
    padding: 12px 22px; border: none; border-radius: 6px; cursor: pointer; font-size: 1em;
    font-weight: 500; background-color: var(--button-bg); color: var(--primary-text);
}
button:hover { background-color: var(--button-hover-bg); }
button[type="submit"] { background-color: var(--highlight-text); color: white; }
button[type="submit"]:hover { background-color: var(--highlight-text); filter: brightness(1.1); }


/* Daily Notes Manager, etc. */
.daily-notes-manager { display: flex; gap: 20px; height: calc(100% - 60px); }
.notes-sidebar { width: 200px; flex-shrink: 0; background-color: var(--tertiary-bg); padding: 15px; border-radius: 8px; border: 1px solid var(--border-color); overflow-y: auto; }
.notes-sidebar h3 { font-size: 1.2em; color: var(--highlight-text); margin-top: 0; margin-bottom: 15px; }
#notes-folder-list { list-style-type: none; padding: 0; margin: 0; }
#notes-folder-list li { padding: 10px 12px; cursor: pointer; border-radius: 6px; margin-bottom: 5px; }
#notes-folder-list li:hover { background-color: var(--accent-bg); }
#notes-folder-list li.active { background-color: var(--highlight-text); color: white; }
.notes-content-area { flex-grow: 1; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; }
.notes-toolbar { display: flex; gap: 10px; align-items: center; padding: 10px; background-color: var(--secondary-bg); border-radius: 8px; border: 1px solid var(--border-color); }
#notes-list-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; }
.note-card { background-color: var(--tertiary-bg); padding: 15px; border: 1px solid var(--border-color); border-radius: 8px; cursor: pointer; }
.note-card:hover { box-shadow: 0 0 8px var(--highlight-text); }
.note-editor-area { display: none; }
#note-content-editor { width: 100%; min-height: 300px; }


/* Loading and Message Popup */
.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.7); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 1001; visibility: hidden; opacity: 0; transition: opacity 0.3s ease; }
.loading-overlay.visible { visibility: visible; opacity: 1; }
.spinner { border: 5px solid var(--accent-bg); border-top: 5px solid var(--highlight-text); border-radius: 50%; width: 45px; height: 45px; animation: spin 0.8s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.message-popup { position: fixed; bottom: -100px; left: 50%; transform: translateX(-50%); background-color: var(--secondary-bg); color: var(--primary-text); padding: 16px 28px; border-radius: 8px; box-shadow: 0 5px 20px rgba(0,0,0,0.3); z-index: 1002; opacity: 0; transition: all 0.4s ease; }
.message-popup.show { bottom: 40px; opacity: 1; }
.message-popup.success { background-color: var(--memory-color); color: white; }
.message-popup.error { background-color: var(--danger-color); color: white; }

/* Styles for Agent and TVS file editors to ensure textarea fills space */
#agent-files-editor-section.active-section, #tvs-files-editor-section.active-section {
    display: flex;
    flex-direction: column;
    height: 100%; /* Make section take full height */
}

.agent-editor-controls, .tvs-editor-controls {
    flex-shrink: 0; /* Prevent controls from shrinking */
    margin-bottom: 15px;
}

#agent-file-content-editor, #tvs-file-content-editor {
    flex-grow: 1; /* Allow textarea to grow and fill available space */
    width: 100%;
    min-height: 400px; /* Set a reasonable minimum height */
    resize: vertical;
    font-family: 'Courier New', Courier, monospace;
}
/* Style for the input and button wrapper */
.input-with-toggle {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-toggle input {
    padding-right: 60px; /* Make space for the button */
    width: 100%;
    box-sizing: border-box;
}

/* Style for the show/hide button */
.toggle-visibility-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    padding: 5px 8px;
    font-size: 0.8em;
    cursor: pointer;
    background-color: var(--button-bg);
    color: var(--primary-text);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    z-index: 2;
}

.toggle-visibility-btn:hover {
    background-color: var(--button-hover-bg);
}

/* --- Styles for Main Editor Textareas --- */
#note-content-editor,
#agent-file-content-editor,
#tvs-file-content-editor {
    background-color: var(--input-bg);
    color: var(--primary-text);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    font-size: 0.95em;
    line-height: 1.6;
    font-family: 'Courier New', Courier, monospace;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#note-content-editor:focus,
#agent-file-content-editor:focus,
#tvs-file-content-editor:focus {
    outline: none;
    border-color: var(--highlight-text);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--highlight-text) 25%, transparent);
}


/* --- Styles for Toolbar Inputs and Selects --- */
.notes-toolbar input[type="search"],
.notes-toolbar select,
.agent-editor-controls select,
.tvs-editor-controls select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--primary-text);
    font-size: 0.9em;
    font-weight: 500;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    height: 42px; /* Match button height */
    box-sizing: border-box;
}

.notes-toolbar button,
.agent-editor-controls button,
.tvs-editor-controls button {
    height: 42px;
    box-sizing: border-box;
}

.notes-toolbar input[type="search"]:focus,
.notes-toolbar select:focus,
.agent-editor-controls select:focus,
.tvs-editor-controls select:focus {
    outline: none;
    border-color: var(--highlight-text);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--highlight-text) 20%, transparent);
}


/* Server Activity Chart Styles */
.activity-chart-container {
    margin-top: 30px;
    padding: 25px;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

html[data-theme='dark'] .activity-chart-container {
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.activity-chart-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1em;
    color: var(--primary-text);
    font-weight: 600;
}

#activity-chart-canvas {
    width: 100%;
    height: 150px; /* Adjust height as needed */
    display: block;
}

/* --- Semantic Groups Editor Styles --- */
.semantic-groups-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

#semantic-groups-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.group-details {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.group-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    background-color: var(--tertiary-bg);
    font-weight: 600;
    font-size: 1.1em;
}

.group-summary:hover {
    background-color: var(--accent-bg);
}

.group-name-display {
    color: var(--highlight-text);
}

.delete-group-btn {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 0.8em;
    border-radius: 5px;
}
html[data-theme='light'] .delete-group-btn {
    color: white;
}
.delete-group-btn:hover {
    background-color: var(--danger-hover-bg);
}

.group-content {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.words-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.word-tag {
    display: inline-flex;
    align-items: center;
    background-color: var(--highlight-text);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9em;
    font-weight: 500;
}

.word-tag.auto-learned {
    background-color: var(--memory-color); /* A different color for AI learned tags */
}

.remove-word-btn {
    margin-left: 8px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    padding: 0 2px;
}

.add-word-input {
    flex-grow: 1;
    min-width: 150px;
    border: none;
    background: transparent;
    color: var(--primary-text);
    padding: 5px;
    font-size: 0.9em;
}

.add-word-input:focus {
    outline: none;
}
